package com.easy.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.easy.common.bean.SysPermission;
import com.easy.common.bean.SysRole;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<SysRole> {
    @Select("select b.* from sys_role_permission a right join  sys_permission b on a.permission_id=b.id where role_id=#{roleid}")
    List<SysPermission> getRolePermissions(@Param("roleid") Integer roleid);

    @Insert("insert into sys_role_permission (role_id,permission_id) value (#{roleid},#{permissionid})")
    int assignPermission(@Param("roleid") Integer roleid,@Param("permissionid") Integer permissionid);

    @Delete("delete from sys_role_permission where role_id=#{roleid}")
    int clearRolePermission(Integer roleid);
}
